package cfsmon.core;

import java.io.InputStream;
import java.io.OutputStream;

import cfsmon.logic.dfm.IDfm;

/**
 * A compiler connects frontend and backend and acts as a proxy
 * abstracting from the actual backend and frontend implementation.
 */
public class Compiler {

	/**
	 * A backend instance (commonly a C code generator)
	 */
	Backend back;
	/**
	 * A frontend instance (commonly a specification parser)
	 */
	Frontend front;
	
	/**
	 * 
	 * @param back
	 * @param front
	 */
	Compiler(Backend back, Frontend front) {
		this.back = back;
		this.front = front;
	}
	
	public void compile(InputStream in, OutputStream out, int monitorSlots) throws Exception{
		IDfm dfm = front.compile(in);
		if (dfm != null)
			back.compile(dfm, out, monitorSlots);
	}
	
}
